#ifndef ANTIALIASING
#define ANTIALIASING
float3 aa(v2p I)
{
float3 result;
if (true) {
half3 nc=tex2D(s_normal,I.tc0);
half4 nd;
nd.x=dot(nc,(half3)tex2D(s_normal,I.tc1));
nd.y=dot(nc,(half3)tex2D(s_normal,I.tc2));
nd.z=dot(nc,(half3)tex2D(s_normal,I.tc3));
nd.w=dot(nc,(half3)tex2D(s_normal,I.tc4));
nd-=AA_BARRIER_X;
nd=step(0,nd);
half ne=saturate(dot(nd,AA_WEIGHTS_X));
float4 tc5r=I.tc5.wzyx;
float4 tc6r=I.tc6.wzyx;
half4 dc=tex2D(s_position,I.tc0);
half4 dd;
dd.x=(half)tex2D(s_position,I.tc1).z+(half)tex2D(s_position,I.tc2).z;
dd.y=(half)tex2D(s_position,I.tc3).z+(half)tex2D(s_position,I.tc4).z;
dd.z=(half)tex2D(s_position,I.tc5).z+(half)tex2D(s_position,tc5r).z;
dd.w=(half)tex2D(s_position,I.tc6).z+(half)tex2D(s_position,tc6r).z;
dd=abs(2*dc.z-dd)-AA_BARRIER_Y;
dd=step(dd,0);
half de=saturate(dot(dd,AA_WEIGHTS_Y));
half w=(1-de*ne)*AA_KERNEL;
#ifdef USE_DISTORT
half4 distort2=tex2D(s_distort,I.tc0);
half2 doffs=(distort2.xy-.5h)*def_distort;
float2 center=I.tc0+doffs;
#else
float2 center=I.tc0;
#endif
float2 offset2=center*(1-w);
half4 s0=tex2D(s_image,offset2+I.tc1*w);
half4 s1=tex2D(s_image,offset2+I.tc2*w);
half4 s2=tex2D(s_image,offset2+I.tc3*w);
half4 s3=tex2D(s_image,offset2+I.tc4*w);
result = (s0+s1+s2+s3)/4.h;
}
else result = tex2D(s_image,I.tc0);
return result;
}
#endif